package com.caijg.controller.user;

import com.caijg.domain.dto.DiagnosisDTO;
import com.caijg.domain.vo.Result;
import com.caijg.service.ITongueDiagnosisService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

/**
 * <p>
 * 舌诊表 前端控制器
 * </p>
 *
 * @author caijg
 * @since 2024-12-27
 */
@RestController
@Tag(name = "舌诊模块")
@RequestMapping("/user/tongue")
@Slf4j
public class UserTongueDiagnosisController {

    @Autowired
    private ITongueDiagnosisService tongueDiagnosisService;

    @PostMapping("/diagnosis")
    @Operation(summary = "舌诊诊断")
    public Result diagnosis(@RequestBody DiagnosisDTO diagnosisDTO) throws Exception {
        log.info("舌诊诊断开始...");
        return tongueDiagnosisService.diagnosis(diagnosisDTO);
    }

    @Operation(summary = "查询舌诊历史记录")
    @GetMapping("/history")
    public Result history() {
        log.info("用户舌诊历史查询...");
        return tongueDiagnosisService.history();
    }

    @Operation(summary = "删除舌诊历史记录")
    @PostMapping("/delete")
    public Result delete(@RequestBody ArrayList<String> ids) {
        log.info("删除舌诊记录：{}", ids);
        return tongueDiagnosisService.delete(ids);
    }

    @Operation(summary = "获取舌苔特征描述")
    @GetMapping("/{id}")
    public Result getById(@PathVariable Integer id) {
        return Result.success(tongueDiagnosisService.getById(id));
    }
}